import { PIXIComponents } from "@/utils/PIXIComponents";
import ParameterMethod from "@/utils/ParameterMethod";
import { positionMap, getChildren } from "@/utils/utils";
const { PIXI, APP, stage } = ParameterMethod;
import importzy from "@/pixi/components/importzy";
import establishAlloytouch from "@/pixi/components/animation";
class Ready extends PIXIComponents {
  // public regist() {
  //   PIXIComponents.setComponents("ready", this.handle.bind(this));
  // }
  public async handle(e: any) {
    const DomEl = e;
    const appview = APP.view;
    const screen = APP.renderer.screen;
    /**
     * 重置舞台大小
     */
    screen.height = DomEl.offsetHeight;
    screen.width = DomEl.offsetWidth;
    appview.height = DomEl.offsetHeight;
    appview.width = DomEl.offsetWidth;
    //end
    const title = this.SetTitle("一镜到底test", "white"); // 设置标题

    await importzy.handle(); // 导入素材并创建场景以及精灵
    await establishAlloytouch.handle(); // 创建动画
  }
  private SetTitle(text: string, color: string): void {
    const title = new PIXI.Text(text, { fill: color, fontSize: "18px" });
    const position = positionMap("bottom");
    title.x = position.x * APP.view.width - title.width / 2;
    title.y = position.y * APP.view.height - title.height / 1;
    stage.addChild(title);
    return title;
  }
}
export default new Ready();
